<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:69:"E:\WWW\newadmin.cc\public/../application/admin\view\admin\update.html";i:1670904725;}*/ ?>


<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/admin/layuiadmin/layui/css/layui.css" media="all">
</head>
<body>
  <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 0 0 0;">
    <style type="text/css">
      .layui-form-label{
        width:100px;
      }
      .layui-form-item .layui-input-inline{
        width: 400px;
      }
    </style>
    
    <!-- 管理员不能修改自己的角色 -->

    <div class="layui-form-item" style="display: <?php if($data['juese']!=1 && $admin['juese']==1){echo 'block';}else{ echo 'none';} ?>;">

      <label class="layui-form-label">选择角色</label>

      <div class="layui-input-inline"  style="width: 600px;">

        <select name="juese"  lay-search lay-filter="juese">
          <option></option>
            <?php if(is_array($rolelist) || $rolelist instanceof \think\Collection || $rolelist instanceof \think\Paginator): $i = 0; $__LIST__ = $rolelist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                  <option  value="<?php echo $vo['id']; ?>" <?php echo $data['juese']==$vo['id']?'selected' : ''; ?>><?php echo $vo['name']; ?></option>
            <?php endforeach; endif; else: echo "" ;endif; ?>

        </select>

      </div>

    </div>
  <?php if($data['juese']==1){ ?>
   <input type="hidden" name="juese" lay-verify="required" placeholder="请输入登录账号" autocomplete="off" class="layui-input" value="1">
  <?php } ?>
    <div class="layui-form-item">
      <label class="layui-form-label">登录账号</label>
      <div class="layui-input-inline"  style="width: 600px;">
        <input type="text" name="adminname" lay-verify="required" placeholder="请输入登录账号" autocomplete="off" class="layui-input" value="<?php echo !empty($data)?$data['adminname'] : ''; ?>">
      </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline"  style="width: 600px;">
          <input type="text" name="name"  placeholder="" autocomplete="off" class="layui-input" value="<?php echo !empty($data)?$data['name'] : ''; ?>">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-inline"  style="width: 600px;">
          <input type="phone"  name="phone"  placeholder="" autocomplete="off" class="layui-input" value="<?php echo !empty($data)?$data['phone'] : ''; ?>">
        </div>
    </div>


    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-front-submit" value="确认">
    </div>
  </div>
  <script src="/static/admin/layuiadmin/layui/layui.js"></script>  
  <script>
  layui.config({
    base: '/static/admin/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form', 'upload'], function(){
    var $ = layui.$
    ,form = layui.form
    ,upload = layui.upload ;

    form.on('select(juese)', function(data){
      if(data.value==3){
        $("#area_div").show();
      }else{
        $("#area_div").hide();
      }
    }); 
    form.on('checkbox(father)', function(data){

        if(data.elem.checked){
            $(data.elem).parent().siblings('td').find('input').prop("checked", true);
            form.render(); 
        }else{
           $(data.elem).parent().siblings('td').find('input').prop("checked", false);
            form.render();  
        }
    });
    form.on('checkbox(son)', function(data){

        if(data.elem.checked){
            $(data.elem).parent().parent().siblings('td').find('input').prop("checked", true);
            form.render(); 
        }

    });
    form.on('select(sheng)', function(data){
      console.log(data.value); //得到被选中的值
      var pid=data.value;
      $.ajax({
           type: "GET",
           url: "<?php echo url('/admin/area/getzi'); ?>",
           data:{pid:pid},
           success: function(res){
               res=JSON.parse(res);
                  console.log(res);
                  var str="<option value=''>请选择</option>";
                  for (var i = 0; i < res.length; i++) {
                    str+="<option value='"+res[i]['Area_code']+"'>"+res[i]['Area_name']+"</option>";

                  }
                  // console.log(str)
                  $("#city").html(str);
                  $("#xian").html('');
                  $("#region").html('');
                  form.render()
           }
        });
    });
    form.on('select(city)', function(data){
      console.log(data.value); //得到被选中的值
      var pid=data.value;
      $.ajax({
           type: "GET",
           url: "<?php echo url('/admin/area/getzi'); ?>",
           data:{pid:pid},
           success: function(res){
               res=JSON.parse(res);
                  console.log(res);
                  var str="<option value=''>请选择</option>";
                  for (var i = 0; i < res.length; i++) {
                    str+="<option value='"+res[i]['Area_code']+"'>"+res[i]['Area_name']+"</option>";

                  }
                  // console.log(str)
                  $("#xian").html(str);
                  $("#region").html('');
                  form.render()
           }
        });
    });
    upload.render({
      elem: '#layuiadmin-upload-useradmin'
      ,url: "<?php echo url('/admin/admin/upload'); ?>"
      ,auto: true //选择文件后自动上传
      // ,bindAction: '#LAY-user-front-submit'
      ,field:'image'
      ,accept: 'images'   //指定允许上传时校验的文件类型
      ,method: 'post'
      ,acceptMime: 'image/*'
      ,multiple: false  
      ,done: function(res){  //执行上传请求后的回调。返回三个参数
        $(this.item).prev("div").children("input").val(res.data)
         $('#demo1').attr('src', "/uploads/admin/"+res.data); //图片链接（base64）
        layer.msg('上传成功', {
                  offset: '15px'
                  ,icon: 1
                  ,time: 1000
                });
      },error:function(res){

      }
    });
    //   //监听提交
    // form.on('submit(LAY-user-front-submit)', function(data){
    //   layer.msg(JSON.stringify(data.field));
    //   console.log(data.field);
    //   return false;
    // });
  })
  </script>
</body>
</html>